﻿{include file=header.html}
<script language="javascript" type="text/javascript" src="{res file=DatePicker/WdatePicker.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/jquery-1.2.6.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/jquery.funkyUI.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/common.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/select.js}"></script>
<script language="javascript" type="text/javascript">
function edit(obj) {
	var row = obj.parentNode.parentNode;
	var tds = row.getElementsByTagName('td');
	$('#item_id').val(tds[0].getElementsByTagName('input')[0].value);
	$('#sourcing_info').html(tds[1].innerHTML);
	$('#fabric_info').val(tds[2].innerHTML);
	$('#fabric_shop_id').val(tds[3].getElementsByTagName('input')[0].value);
	if (tds[3].innerText) {
		if (tds[3].innerText != '') {
			$('#fabric_shop_name').val(tds[3].innerText);
		} else {
			$('#fabric_shop_name').val('{$lang.select_pls}');
		}
	} else {
		if (tds[3].textContent != '') {
			$('#fabric_shop_name').val(tds[3].textContent);
		} else {
			$('#fabric_shop_name').val('{$lang.select_pls}');
		}
	}
	$('#update').show();
	$('#cancel_submit').show();
}
<!--{if $sourcing_task.sourcing_accept}-->
function cancel()
{
	$('#item_id').val(0);
	$('#sourcing_info').html('');
	$('#fabric_info').val('');
	$('#fabric_shop_id').val(0);
	$('#fabric_shop_name').val('{$lang.select_pls}');
	$('#update').hide();
	$('#cancel_submit').hide();
}
<!--{/if}-->
</script>
<body>
<div class="sub-body">
<h3 class="title-1">{$lang.sourcing_task_manage}</h3>
<div class="tab-frame">
    <div class="tab-title-1"><span>{$lang.sourcing_infom}</span></div>
    <table cellspacing="0" cellpadding="0" class="tab-add" id="tab-color3">
      <tr>
        <td>{$lang.list_sn}：</td>
        <td colspan="5" class="tab-align-l">{$sourcing_task.list_sn|escape}</td>
      </tr>
	  <!--{if $sourcing_task.type == 1}-->
      <tr>
        <td>{$lang.sample_sn}：</td>
        <td colspan="5" class="tab-align-l">{$sourcing_task.sample_sn|escape}</td>
      </tr>
	  <!--{else}-->
      <tr>
        <td>{$lang.order_sn}：</td>
        <td colspan="5" class="tab-align-l">{$sourcing_task.order_sn|escape}</td>
      </tr>
	  <!--{/if}-->
      <tr>
        <td>{$lang.merchandiser}：</td>
        <td colspan="5" class="tab-align-l">{$sourcing_task.user_name|escape}</td>
      </tr>
	  <!--{if $sourcing_task.status == 2}-->
      <tr>
        <td>{$lang.sourcing_info}：</td>
        <td colspan="5" class="tab-align-l" id="sourcing_info"></td>
      </tr>
	  <form method="post" action="{url app=sourcing_task&act=edit&id=$smarty.get.id}" id="submit_form">
      <tr>
        <td>{$lang.fabric_info}：</td>
        <td class="tab-align-l"><textarea name="fabric_info" id="fabric_info" cols="45" rows="5"></textarea></td>
		<td colspan="4" align="left" valign="middle"><!--{if $sourcing_task.sourcing_accept}--><input type="submit" class="btn-2" value="{$lang.update}" style="display:none;" id="update" /><input type="button" class="btn-2" value="{$lang.cancel}" style="display:none; margin-left:1em;" id="cancel_submit" onClick="cancel();" /><!--{/if}--></td>
      </tr>
      <tr>
        <td>{$lang.fabric_shop_name}：</td>
        <td class="tab-align-l" colspan="5">
		<div class="select-input">
			<input type="text" id="fabric_shop_name" class="input-2" style="width:300px;" onFocus="show_select('fabric_shop_name', 'select_txt');" onBlur="hide_select('fabric_shop_name', 'fabric_shop_id', 'select_txt');" onKeyUp="input_select(this.value, 'fabric_shop_id', event);" value="{$lang.select_pls}" /> <input type="hidden" name="fabric_shop_id" id="fabric_shop_id" value="0" />
			<div class="select-txt" id="select_txt" style="display:none;">
				<ul>
		  			<!--{foreach from=$fabric_shop_list item=fabric_shop}-->
					<li onMouseOver="over_select(this, 'over');" onMouseOut="out_select(this);" onMouseDown="down_select(this, 'fabric_shop_name', 'fabric_shop_id', {$fabric_shop.fabric_shop_id});">{$fabric_shop.fabric_shop_name}</li>
					<!--{/foreach}-->
				</ul>
			</div>
			<input type="hidden" id="item_id" name="item_id" value="0">
        <input type="button" class="btn-2" value="{$lang.add}" onClick="AjaxAddFabricShop();" style="margin-left:2em;"/>
		</div></td>
      </tr>
	  </form>
	  <!--{/if}-->
      <tr>
        <td colspan="6">&nbsp;</td>
      </tr>
      <tr>
        <th>{$lang.No}</th>
        <th>{$lang.sourcing_info}</th>
        <th>{$lang.fabric_info}</th>
        <th>{$lang.fabric_shop_name}</th>
        <th>{$lang.status}</th>
        <th>{$lang.handle}</th>
      </tr>
	  <!--{foreach from=$sourcing_task.item item=item name=it}-->
      <tr>
        <td width="70">{$smarty.foreach.it.iteration}<input type="hidden" value="{$item.item_id|escape}"></td>
        <td width="300">{$item.sourcing_info|escape}</td>
        <td width="300">{$item.fabric_info|escape}</td>
        <td width="200">{$item.fabric_shop_name|escape}<input type="hidden" value="{$item.fabric_shop_id}" /></td>
        <td>{$lang.souritem_status.$item.status}</td>
        <td><!--{if $item.status == 2}--><input type="button" class="btn-s-1" value="{$lang.modify}" onClick="{if $item.status < 2}alert('{$lang.before_accept_can_not_modify}');{elseif $item.status > 2}alert('{$lang.after_finish_can_not_modify}');{else}edit(this);{/if}"/><!--{/if}--></td>
      </tr>
	  <!--{/foreach}-->
      <tr>
        <td>{$lang.enclosure}：</td>
        <td id="sourcing_files">
		<!--{foreach from=$sourcing_task.files item=file}-->
		<a href="download.php?id={$file.file_id}">{$file.file_name|escape}</a><a class="pic_del" href="{url app=comupload&act=delete&id=$file.file_id}" onClick="return confirm('{$lang.confirm_del_file}')" title="{$lang.delete}">&nbsp;</a><!--{if !$smarty.foreach.last}--><br /><!--{/if}-->
		<!--{/foreach}-->
        </td>
        <td class="tab-align-l"><input type="button" class="btn-3" value="{$lang.upload_enclosure}" onClick="upload_docs({$belongs_sourcing_list}, {$sourcing_task.list_id});" /></td>
        <td colspan="3">
		<!--{if $sourcing_task.status == 1}-->
		<span class="tab-align-l"><input type="button" class="btn-2" value="{$lang.accept}" onClick="if(confirm('{$lang.confirm_accept}')){location.href='{url app=sourcing_task&act=accept&id=$smarty.get.id}'}" /></span>
		<!--{elseif $sourcing_task.status < 3}-->
		<span class="tab-align-l"><input type="button" class="btn-2" value="{$lang.print_sourcing_list}" onClick="window.open('{url app=sourcing_task&act=print_&id=$smarty.get.id}')" /></span>
		<span class="tab-align-l"><input type="button" class="btn-2" value="{$lang.finish}" onClick="if(confirm('{$lang.confirm_finish}')){location.href='{url app=sourcing_task&act=finish&id=$smarty.get.id}'}" /></span>
		<!--{/if}-->
		</td>
      </tr>
    </table>

  </div>
{include file=page.html}
</div>
<script language="javascript" type="text/javascript" src="{res file=js/tab_color.js}"></script>
</body>
</html>